# Generated via
#  `rails generate active_fedora:model <%= class_name %>`
require 'rails_helper'
require 'active_fedora/test_support'

describe <%= class_name %> do
  it_behaves_like 'An ActiveModel'
  include ActiveFedora::TestSupport
  subject { <%= class_name %>.new }

  describe "when persisted to fedora" do
    before { subject.save! }
    after { subject.destroy }
    it 'should exist' do
      expect(<%= class_name %>.exists?(subject.id)).to be true
    end
  end

  <% if options['datastream'] %>
  it 'should have a descMetadata datastream' do
    expect(subject.descMetadata).to be_kind_of <%= options['descMetadata'] ? options['descMetadata'] : "#{class_name}Metadata" %>
  end
  <% else %>
  it 'should have a title' do
    subject.title = ['War and Peace']
    expect(subject.title).to eq ['War and Peace']
  end

  describe "#to_solr" do
    subject { <%= class_name %>.new(title: ['War and Peace']).to_solr }

    it 'should have a title' do
      expect(subject['title_tesim']).to eq ['War and Peace']
    end
  end
  <% end %>

end
